/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.click.app.service.impl;

import com.click.app.dao.ProductDao;
import com.click.app.model.LabelValue;
import com.click.app.model.Product;
import com.click.app.service.ProductManager;
import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 *
 * @author arnold
 */
public class ProductManagerImpl extends GenericManagerImpl<Product, Long> implements ProductManager {

    ProductDao productDao;

    public ProductManagerImpl(ProductDao productDao) {
        super(productDao);
        this.productDao = productDao;
    }

    public List<Product> findById(Long id) {
        return productDao.findById(id);
    }

    public List<LabelValue> getProductLabelValue() {
        return productDao.getAllLabelValue();
    }

    public ProductDao getProductDao() {
        return productDao;
    }

    public Float getHighestPrice(Product p){
        return productDao.getHighestPrice(p);
    }

    public void setProductDao(ProductDao productDao) {
        this.productDao = productDao;
    }

    public List<Product> findProductByFeatureProduct(List<String> names, List<String> operatorNames, List<String> values, List<String> operatorValues, List<String> joinsFields) {
        return productDao.findProductByFeatureProduct(names, operatorNames, values, operatorValues, joinsFields);
    }

    public List<Product> findAllIds(List<Long> listIds) {
        List<Product> res = new ArrayList<Product>();
        for (Iterator<Long> it = listIds.iterator(); it.hasNext();) {
            Long idLong = it.next();
            Product mat = this.get(idLong);
            if (mat != null) {
                res.add(mat);
            }
        }
        return res;
    }

    public List<Product> getAllPrices() {
        return productDao.getAllPrices();
    }
}

